package com.af.robot;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import javax.swing.filechooser.FileSystemView;
import java.io.*;

@SpringBootApplication
@Slf4j
public class RobotApplication {

    public static void main(String[] args) {
        System.setProperty("java.awt.headless", "false");
        SpringApplication.run(RobotApplication.class, args);
        creatHomeLink();
    }

    public static void  creatHomeLink(){
        try {
            File link = new File(FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + "\\服务管理器.url");
            if (!link.exists()){
                //创建快捷方式
                BufferedWriter out = new BufferedWriter(new FileWriter(link));
                out.write("[InternetShortcut]\n");
                out.write("URL=http://127.0.0.1:18951\n");
                out.flush();
                out.close();
            }
        } catch (IOException e) {
            log.error("创建桌面快捷方式失败！");
        }

    }

}
